package com.aspose.cells.a.c;

import com.aspose.cells.DateTime;
import com.aspose.cells.zafy;
import com.aspose.cells.zasq;
import com.aspose.cells.zxx;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.TimeZone;

public class zp {
   private static final String[] a = new String[]{"0.E00", "0.#E00", "0.##E00", "0.###E00", "0.####E00", "0.#####E00", "0.######E00", "0.#######E00", "0.########E00", "0.#########E00", "0.##########E00"};
   private static final String[] b = new String[]{"0.#", "0.##", "0.###", "0.####", "0.#####", "0.######", "0.#######", "0.########", "0.#########", "0.##########"};
   private static final HashMap<Integer, HashMap<String, DecimalFormat>> c = new HashMap(8);
   private static final HashMap<String, DecimalFormat> d = new HashMap(64);
   private static final HashMap<Integer, HashMap<String, SimpleDateFormat>> e = new HashMap(8);
   private static final HashMap<String, SimpleDateFormat> f = new HashMap(64);
   private static final TimeZone g = TimeZone.getTimeZone("GMT");
   private static final HashMap<Integer, zxx> h = new HashMap(8);

   private static String f(int var0) {
      char[] var1 = new char[var0 + 2];
      var1[0] = '0';
      var1[1] = '.';

      for(int var2 = var0 + 1; var2 > 1; ++var2) {
         var1[var2] = '#';
      }

      return new String(var1);
   }

   public static String a(DateTime var0) {
      StringBuilder var1 = new StringBuilder(20);
      zasq.a(var0, var1);
      return var1.toString();
   }

   public static void a(DateTime var0, StringBuilder var1) {
      if (var0 != null) {
         zasq.b(var0, var1);
      }
   }

   public static double a(String var0) {
      return Double.parseDouble(var0);
   }

   public static int b(String var0) {
      return com.aspose.cells.b.a.zo.a(var0, 7, com.aspose.cells.b.a.c.za.b());
   }

   public static int c(String var0) {
      return com.aspose.cells.b.a.zo.a(var0, 515, com.aspose.cells.b.a.c.za.b());
   }

   public static String a(byte var0) {
      return Integer.toString(var0 & 255);
   }

   public static String a(long var0) {
      return Long.toString(var0);
   }

   public static String a(int var0) {
      return Integer.toString(var0);
   }

   public static String b(int var0) {
      return Integer.toHexString(var0).toUpperCase();
   }

   public static String c(int var0) {
      switch(var0) {
      case 0:
         return "00";
      case 1:
         return "01";
      case 2:
         return "02";
      case 3:
         return "03";
      case 4:
         return "04";
      case 5:
         return "05";
      case 6:
         return "06";
      case 7:
         return "07";
      case 8:
         return "08";
      case 9:
         return "09";
      case 10:
         return "0A";
      case 11:
         return "0B";
      case 12:
         return "0C";
      case 13:
         return "0D";
      case 14:
         return "0E";
      case 15:
         return "0F";
      default:
         return Integer.toHexString(var0).toUpperCase();
      }
   }

   public static String d(int var0) {
      String var1 = Integer.toHexString(var0).toUpperCase();
      switch(var1.length()) {
      case 1:
         return "000" + var1;
      case 2:
         return "00" + var1;
      case 3:
         return "0" + var1;
      default:
         return var1;
      }
   }

   public static String e(int var0) {
      String var1 = Integer.toHexString(var0).toUpperCase();
      switch(var1.length()) {
      case 1:
         return "0000000" + var1;
      case 2:
         return "000000" + var1;
      case 3:
         return "00000" + var1;
      case 4:
         return "0000" + var1;
      case 5:
         return "000" + var1;
      case 6:
         return "00" + var1;
      case 7:
         return "0" + var1;
      default:
         return var1;
      }
   }

   public static String a(int var0, int var1) {
      StringBuilder var2 = new StringBuilder(var1 > 10 ? var1 : 10);
      zasq.a(var0, var1, var2);
      return var2.toString();
   }

   public static void a(int var0, int var1, StringBuilder var2) {
      zasq.a(var0, var1, var2);
   }

   public static String a(double var0) {
      return com.aspose.cells.a.a.zb.c.format(var0);
   }

   public static String a(double var0, int var2) {
      return var2 <= b.length ? a(d, b[var2 - 1]).format(var0) : (new DecimalFormat(f(var2), com.aspose.cells.a.a.zb.a)).format(var0);
   }

   public static void a(double var0, int var2, StringBuilder var3) {
      var3.append(a(var0, var2));
   }

   public static String a(double var0, String var2, com.aspose.cells.b.a.c.za var3) {
      return a(a(var3), var2).format(var0);
   }

   public static String a(DateTime var0, String var1) {
      return var0 == null ? "" : a(com.aspose.cells.b.a.c.za.a(), var1).format(var0.j());
   }

   public static String a(DateTime var0, String var1, com.aspose.cells.b.a.c.za var2) {
      return var0 == null ? "" : a(var2, var1).format(var0.j());
   }

   public static String a(double var0, String var2) {
      return b(var0, var2, com.aspose.cells.b.a.c.za.a());
   }

   public static String b(double var0, String var2, com.aspose.cells.b.a.c.za var3) {
      int var4 = var2.indexOf(69);
      if (var4 > -1 && var4 < var2.length() - 2 && var2.charAt(var4 + 1) == '+' && var2.indexOf(69, var4 + 2) < 0) {
         String var5 = a(var0, var2.substring(0, var4 + 1) + var2.substring(var4 + 2), var3);
         var4 = var5.indexOf(69);
         return var5.substring(0, var4 + 1) + "+" + var5.substring(var4 + 1);
      } else {
         return a(b(var3), var2, var0);
      }
   }

   private static HashMap<String, DecimalFormat> a(com.aspose.cells.b.a.c.za var0) {
      Integer var1 = var0.g();
      HashMap var2 = (HashMap)c.get(var1);
      if (var2 == null) {
         var2 = new HashMap(32);
         c.put(var1, var2);
         if (zl.a() && c.size() > 20) {
            zl.a("Check the program for formatting numeric values, current cached locales are " + c.size());
         }

         var2.put("0.####", new DecimalFormat("0.####", new DecimalFormatSymbols(var0.h())));
      }

      return var2;
   }

   private static DecimalFormat a(HashMap<String, DecimalFormat> var0, String var1) {
      DecimalFormat var2 = (DecimalFormat)var0.get(var1);
      if (var2 == null) {
         var2 = new DecimalFormat(var1, ((DecimalFormat)var0.get("0.####")).getDecimalFormatSymbols());
         var0.put(var1, var2);
         if (zl.a() && var0.size() > 64) {
            zl.a("Check the program for formatting numeric values, current cached formattings are " + var0.size());
         }
      }

      return var2;
   }

   private static SimpleDateFormat a(com.aspose.cells.b.a.c.za var0, String var1) {
      Integer var2 = var0.g();
      HashMap var3 = (HashMap)e.get(var2);
      SimpleDateFormat var4;
      if (var3 == null) {
         var3 = new HashMap(32);
         e.put(var2, var3);
         if (zl.a() && e.size() > 20) {
            zl.a("Check the program for formatting datetime values, current cached locales are " + e.size());
         }

         var4 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
         var4.setTimeZone(g);
         var3.put("yyyy-MM-dd'T'HH:mm:ss", var4);
      }

      var4 = (SimpleDateFormat)var3.get(var1);
      if (var4 == null) {
         var4 = new SimpleDateFormat(var1);
         var4.setTimeZone(g);
         var3.put(var1, var4);
         if (zl.a() && var3.size() > 64) {
            zl.a("Check the program for formatting datetime values, current cached formattings are " + var3.size());
         }
      }

      return var4;
   }

   private static zxx b(com.aspose.cells.b.a.c.za var0) {
      Integer var1 = var0.g();
      zxx var2 = (zxx)h.get(var1);
      if (var2 == null) {
         var2 = new zxx(var0);
         h.put(var1, var2);
         if (zl.a() && h.size() > 20) {
            zl.a("Check the program for formatting values, current cached locales are " + h.size());
         }
      }

      return var2;
   }

   private static String a(zxx var0, String var1, double var2) {
      zafy var4 = var0.a(var1, true);
      synchronized(var4) {
         return var4.a(var0.j(), 14, var2).h();
      }
   }

   public static String b(double var0) {
      return (double)((long)var0) == var0 ? Long.toString((long)var0) : Double.toString(var0);
   }

   public static String c(double var0) {
      return a(var0);
   }

   public static String d(double var0) {
      return a(var0, 9);
   }

   public static String a(float var0) {
      return a((double)var0, 8);
   }

   public static String b(float var0) {
      return a((double)var0, 9);
   }

   static {
      d.put("0.####", new DecimalFormat("0.####", com.aspose.cells.a.a.zb.a));
      c.put(1033, d);
      SimpleDateFormat var0 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US);
      var0.setTimeZone(g);
      f.put("yyyy-MM-dd'T'HH:mm:ss", var0);
      e.put(1033, f);
   }
}
